package com.ycsj.goldmedalnewconcept.fragment;

import android.app.Activity;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.GridView;
import android.widget.ImageView;
import android.widget.TextView;

import com.ycsj.goldmedalnewconcept.MainActivity;
import com.ycsj.goldmedalnewconcept.R;

//课时查询
public class ClassQueryFragment extends Fragment {
	
	private Activity ctx;
	private View layout;
	private MainActivity parentActivity;	
	private GridView gridview_classquery;
	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container,
			Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		if (layout == null) {
			ctx = this.getActivity();
			parentActivity = (MainActivity) getActivity();
			layout = ctx.getLayoutInflater().inflate(R.layout.fragment_classquery,
					null);
		} else {
			ViewGroup parent = (ViewGroup) layout.getParent();
			if (parent != null) {
				parent.removeView(layout);
			}
		}
		initView(layout);
		initdate();
		return layout;
	}

	private void initView(View layout2) {
		// TODO Auto-generated method stub
		gridview_classquery = (GridView) layout2.findViewById( R.id.gridview_classquery );
	}
	private void initdate() {
		gridview_classquery.setAdapter(new MyAdapter());
	}
	
	
	
	class MyAdapter extends BaseAdapter{
		private LayoutInflater inflater= LayoutInflater.from(getActivity());
		@Override
		public int getCount() {
			// TODO Auto-generated method stub
			return 72;
		}

		@Override
		public Object getItem(int position) {
			// TODO Auto-generated method stub
			return null;
		}

		@Override
		public long getItemId(int position) {
			// TODO Auto-generated method stub
			return 0;
		}

		@Override
		public View getView(int position, View convertView, ViewGroup parent) {
			
			ViewHolder viewHolder;
			if (convertView == null) {
				convertView = inflater.inflate(R.layout.gv_item_classquery, null);
				viewHolder = new ViewHolder();
				
				convertView.setTag(viewHolder);
			} else {
				viewHolder = (ViewHolder) convertView.getTag();
			}
			
			
			return convertView;
		}
		class ViewHolder {
			public TextView title;
			public ImageView image;
			public TextView tv_birthday;
		}
	}
	
	
}
